package com.ftg.elvis.service;

import com.ftg.elvis.mapper.AdminCommentMapper;
import com.ftg.elvis.pojo.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminCommentService {

	@Autowired
	AdminCommentMapper adminCommentMapper;

	public List<Comment> showAll(int page, int limit, String comment, String bname, String state) {
		page = (page - 1) * limit;
		comment = comment == null ? "" : comment;
		bname = bname == null ? "" : bname;
		state = state == null ? "" : state;

		return adminCommentMapper.showAll(page, limit, comment, bname, state);
	}

	public int getCount(String comment, String bname, String state) {
		comment = comment == null ? "" : comment;
		bname = bname == null ? "" : bname;
		state = state == null ? "" : state;
		return adminCommentMapper.getCount(comment, bname, state);
	}

	public int delete(String cid) {
		return adminCommentMapper.delete(cid);
	}

	public int reply(String cid, String reply) {
		return adminCommentMapper.reply(cid, reply);
	}
}
